-- These API functions are deprecated and will be removed in patch 11.0.2
-- 10.0.0
CursorCanGoInSlot = CursorCanGoInSlot or C_PaperDollInfo.CanCursorCanGoInSlot

-- 10.0.7
Enum.GarrisonType["Type_6_0"] = Enum.GarrisonType["Type_6_0"] or Enum.GarrisonType["Type_6_0_Garrison"]
Enum.GarrisonType["Type_7_0"] = Enum.GarrisonType["Type_7_0"] or Enum.GarrisonType["Type_7_0_Garrison"]
Enum.GarrisonType["Type_8_0"] = Enum.GarrisonType["Type_8_0"] or Enum.GarrisonType["Type_8_0_Garrison"]
Enum.GarrisonType["Type_9_0"] = Enum.GarrisonType["Type_9_0"] or Enum.GarrisonType["Type_9_0_Garrison"]

Enum.GarrisonFollowerType["FollowerType_6_0"] = Enum.GarrisonFollowerType["FollowerType_6_0"] or Enum.GarrisonFollowerType["FollowerType_6_0_GarrisonFollower"]
Enum.GarrisonFollowerType["FollowerType_6_2"] = Enum.GarrisonFollowerType["FollowerType_6_2"] or Enum.GarrisonFollowerType["FollowerType_6_0_Boat"]
Enum.GarrisonFollowerType["FollowerType_7_0"] = Enum.GarrisonFollowerType["FollowerType_7_0"] or Enum.GarrisonFollowerType["FollowerType_7_0_GarrisonFollower"]
Enum.GarrisonFollowerType["FollowerType_8_0"] = Enum.GarrisonFollowerType["FollowerType_8_0"] or Enum.GarrisonFollowerType["FollowerType_8_0_GarrisonFollower"]
Enum.GarrisonFollowerType["FollowerType_9_0"] = Enum.GarrisonFollowerType["FollowerType_9_0"] or Enum.GarrisonFollowerType["FollowerType_9_0_GarrisonFollower"]

-- 10.1.0
GetAddOnMetadata = GetAddOnMetadata or C_AddOns.GetAddOnMetadata

-- 10.1.5
GetClassIDFromSpecID = GetClassIDFromSpecID or C_SpecializationInfo.GetClassIDFromSpecID

-- 10.2.0
GetCVarInfo = GetCVarInfo or C_CVar.GetCVarInfo
EnableAddOn = EnableAddOn or C_AddOns.EnableAddOn
DisableAddOn = DisableAddOn or C_AddOns.DisableAddOn
GetAddOnEnableState = GetAddOnEnableState or C_AddOns.GetAddOnEnableState
LoadAddOn = LoadAddOn or C_AddOns.LoadAddOn
IsAddOnLoaded = IsAddOnLoaded or C_AddOns.IsAddOnLoaded
EnableAllAddOns = EnableAllAddOns or C_AddOns.EnableAllAddOns
DisableAllAddOns = DisableAllAddOns or C_AddOns.DisableAllAddOns
GetAddOnInfo = GetAddOnInfo or C_AddOns.GetAddOnInfo
GetAddOnDependencies = GetAddOnDependencies or C_AddOns.GetAddOnDependencies
GetAddOnOptionalDependencies = GetAddOnOptionalDependencies or C_AddOns.GetAddOnOptionalDependencies
GetNumAddOns = GetNumAddOns or C_AddOns.GetNumAddOns
SaveAddOns = SaveAddOns or C_AddOns.SaveAddOns
ResetAddOns = ResetAddOns or C_AddOns.ResetAddOns
ResetDisabledAddOns = ResetDisabledAddOns or C_AddOns.ResetDisabledAddOns
IsAddonVersionCheckEnabled = IsAddonVersionCheckEnabled or C_AddOns.IsAddonVersionCheckEnabled
SetAddonVersionCheck = SetAddonVersionCheck or C_AddOns.SetAddonVersionCheck
IsAddOnLoadOnDemand = IsAddOnLoadOnDemand or C_AddOns.IsAddOnLoadOnDemand

-- 10.2.5
FillLocalizedClassList = FillLocalizedClassList or function(tbl, isFemale)
    return LocalizedClassList(isFemale)
end
GetSetBonusesForSpecializationByItemID = GetSetBonusesForSpecializationByItemID or C_Item.GetSetBonusesForSpecializationByItemID
GetItemStats = GetItemStats or C_Item.GetItemStats
GetItemStatDelta = GetItemStatDelta or C_Item.GetItemStatDelta
UnitAura = UnitAura or C_UnitAuras.GetAuraDataByIndex
UnitBuff = UnitBuff or C_UnitAuras.GetBuffDataByIndex
UnitDebuff = UnitDebuff or C_UnitAuras.GetDebuffDataByIndex
UnitAuraBySlot = UnitAuraBySlot or function(unit, slot)
    local aura = C_UnitAuras.GetAuraDataBySlot(unit, slot)
    if aura then
        return aura.name, aura.icon, aura.applications, aura.dispelName, aura.duration, aura.expirationTime, aura.sourceUnit, aura.isStealable, aura.nameplateShowPersonal, aura.spellId,
            aura.canApplyAura, aura.isBossAura, aura.isFromPlayerOrPlayerPet, aura.nameplateShowAll, aura.timeMod
    end
    return nil
end
UnitAuraSlots = UnitAuraSlots or C_UnitAuras.GetAuraSlots

-- 10.2.6
FrameXML_Debug = FrameXML_Debug or C_Debug.FrameXMLDebug
GetMawPowerLinkBySpellID = GetMawPowerLinkBySpellID or C_Spell.GetMawPowerLinkBySpellID

-- 10.2.7
ClosePetStables = ClosePetStables or C_StableInfo.ClosePetStables
GetStablePetInfo = GetStablePetInfo or function(index)
    local petInfo = C_StableInfo.GetStablePetInfo(index)
    if petInfo then
        return petInfo.icon, petInfo.name, petInfo.level, petInfo.familyName, petInfo.specialization
    end
    return nil
end
PickupStablePet = PickupStablePet or C_StableInfo.PickupStablePet
GetStablePetFoodTypes = GetStablePetFoodTypes or C_StableInfo.GetStablePetFoodTypes
IsAtStableMaster = IsAtStableMaster or C_StableInfo.IsAtStableMaster
SetPetSlot = SetPetSlot or C_StableInfo.SetPetSlot
PetAbandon = PetAbandon or C_PetInfo.PetAbandon
PetRename = PetRename or C_PetInfo.PetRename
-- PetCanBeRenamed

-- 11.0.0
GetSpellInfo = GetSpellInfo or function(spell)
    local spellInfo = C_Spell.GetSpellInfo(spell)
    if spellInfo then
        return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID
    end
    return nil
end
GetNumSpellTabs = GetNumSpellTabs or C_SpellBook.GetNumSpellBookSkillLines
GetSpellTabInfo = GetSpellTabInfo or function(tabIndex)
    local skillLineInfo = C_SpellBook.GetSpellBookSkillLineInfo(tabIndex)
    if skillLineInfo then
        return skillLineInfo.name, skillLineInfo.iconID, skillLineInfo.itemIndexOffset, skillLineInfo.numSpellBookItems, skillLineInfo.isGuild, skillLineInfo.offSpecID
    end
    return nil
end
GetSpellCooldown = GetSpellCooldown or function(spell)
    local spellCooldownInfo = C_Spell.GetSpellCooldown(spell)
    if spellCooldownInfo then
        return spellCooldownInfo.startTime, spellCooldownInfo.duration, spellCooldownInfo.isEnabled, spellCooldownInfo.modRate
    end
    return nil
end
GetSpellBookItemName = GetSpellBookItemName or function(spellName, bookType)
    local name, subName
    if type(spellName) == "number" then
        if not bookType then
            print("bookType is nil")
            return nil
        end
        if bookType == "pet" then
            bookType = Enum.SpellBookSpellBank.Pet
        else
            bookType = Enum.SpellBookSpellBank.Player
        end
        name, subName = C_SpellBook.GetSpellBookItemName(spellBookItemSlotIndex, spellBookItemSpellBank)
    else
        local spellFound = false
        for i = 1, C_SpellBook.GetNumSpellBookSkillLines() do
            local skillLineInfo = C_SpellBook.GetSpellBookSkillLineInfo(i)
            local offset, numSlots = skillLineInfo.itemIndexOffset, skillLineInfo.numSpellBookItems
            for j = offset + 1, offset + numSlots do
                local tempName, tempSubName = C_SpellBook.GetSpellBookItemName(j, Enum.SpellBookSpellBank.Player)
                if tempName == spellName then
                    spellFound = true
                    name, subName = tempName, tempSubName
                end
            end
        end
        if not spellFound then
            print("Spell not found")
            return nil
        end
    end
    local spellInfo = C_Spell.GetSpellInfo(name)
    return name, subName, spellInfo.spellID
end
GetSpellTexture = GetSpellTexture or C_Spell.GetSpellTexture
GetSpellCharges = GetSpellCharges or function(spell)
    local chargeInfo = C_Spell.GetSpellCharges(spell)
    if chargeInfo then
        return chargeInfo.currentCharges, chargeInfo.maxCharges, chargeInfo.cooldownStartTime, chargeInfo.cooldownDuration, chargeInfo.chargeModRate
    end
    return nil
end
GetSpellDescription = GetSpellDescription or C_Spell.GetSpellDescription
GetSpellCount = GetSpellCount or C_Spell.GetSpellCastCount
IsUsableSpell = IsUsableSpell or C_Spell.IsSpellUsable

-- These functions were deprecated in patch 10.2.6 but do not appear to be removed on the 11.0.2 beta.

-- Deprecated_CurrencyScript.lua
GetCoinIcon = GetCoinIcon or C_CurrencyInfo.GetCoinIcon
GetCoinText = GetCoinText or C_CurrencyInfo.GetCoinText
GetCoinTextureString = GetCoinTextureString or C_CurrencyInfo.GetCoinTextureString

-- Deprecated_GuildScript.lua
GuildInvite = GuildInvite or C_GuildInfo.Invite
GuildUninvite = GuildUninvite or C_GuildInfo.Uninvite
GuildPromote = GuildPromote or C_GuildInfo.Promote
GuildDemote = GuildDemote or C_GuildInfo.Demote
GuildSetLeader = GuildSetLeader or C_GuildInfo.SetLeader
GuildSetMOTD = GuildSetMOTD or C_GuildInfo.SetMOTD
GuildLeave = GuildLeave or C_GuildInfo.Leave
GuildDisband = GuildDisband or C_GuildInfo.Disband

-- Deprecated_ItemScript.lua
GetItemQualityColor = GetItemQualityColor or C_Item.GetItemQualityColor
GetItemInfoInstant = GetItemInfoInstant or C_Item.GetItemInfoInstant
GetItemSetInfo = GetItemSetInfo or C_Item.GetItemSetInfo
GetItemChildInfo = GetItemChildInfo or C_Item.GetItemChildInfo
DoesItemContainSpec = DoesItemContainSpec or C_Item.DoesItemContainSpec
GetItemGem = GetItemGem or C_Item.GetItemGem
GetItemCreationContext = GetItemCreationContext or C_Item.GetItemCreationContext
GetItemIcon = GetItemIcon or C_Item.GetItemIconByID
GetItemFamily = GetItemFamily or C_Item.GetItemFamily
GetItemSpell = GetItemSpell or C_Item.GetItemSpell
IsArtifactPowerItem = IsArtifactPowerItem or C_Item.IsArtifactPowerItem
IsCurrentItem = IsCurrentItem or C_Item.IsCurrentItem
IsUsableItem = IsUsableItem or C_Item.IsUsableItem
IsHelpfulItem = IsHelpfulItem or C_Item.IsHelpfulItem
IsHarmfulItem = IsHarmfulItem or C_Item.IsHarmfulItem
IsConsumableItem = IsConsumableItem or C_Item.IsConsumableItem
IsEquippableItem = IsEquippableItem or C_Item.IsEquippableItem
IsEquippedItem = IsEquippedItem or C_Item.IsEquippedItem
IsEquippedItemType = IsEquippedItemType or C_Item.IsEquippedItemType
ItemHasRange = ItemHasRange or C_Item.ItemHasRange
IsItemInRange = IsItemInRange or C_Item.IsItemInRange
GetItemClassInfo = GetItemClassInfo or C_Item.GetItemClassInfo
GetItemInventorySlotInfo = GetItemInventorySlotInfo or C_Item.GetItemInventorySlotInfo
BindEnchant = BindEnchant or C_Item.BindEnchant
ActionBindsItem = ActionBindsItem or C_Item.ActionBindsItem
ReplaceEnchant = ReplaceEnchant or C_Item.ReplaceEnchant
ReplaceTradeEnchant = ReplaceTradeEnchant or C_Item.ReplaceTradeEnchant
ConfirmBindOnUse = ConfirmBindOnUse or C_Item.ConfirmBindOnUse
ConfirmOnUse = ConfirmOnUse or C_Item.ConfirmOnUse
ConfirmNoRefundOnUse = ConfirmNoRefundOnUse or C_Item.ConfirmNoRefundOnUse
DropItemOnUnit = DropItemOnUnit or C_Item.DropItemOnUnit
EndBoundTradeable = EndBoundTradeable or C_Item.EndBoundTradeable
EndRefund = EndRefund or C_Item.EndRefund
GetItemInfo = GetItemInfo or C_Item.GetItemInfo
GetDetailedItemLevelInfo = GetDetailedItemLevelInfo or C_Item.GetDetailedItemLevelInfo
GetItemSpecInfo = GetItemSpecInfo or C_Item.GetItemSpecInfo
GetItemUniqueness = GetItemUniqueness or C_Item.GetItemUniqueness
GetItemCount = GetItemCount or C_Item.GetItemCount
PickupItem = PickupItem or C_Item.PickupItem
GetItemSubClassInfo = GetItemSubClassInfo or C_Item.GetItemSubClassInfo
UseItemByName = UseItemByName or C_Item.UseItemByName
EquipItemByName = EquipItemByName or C_Item.EquipItemByName
ReplaceTradeskillEnchant = ReplaceTradeskillEnchant or C_Item.ReplaceTradeskillEnchant
GetItemCooldown = GetItemCooldown or C_Item.GetItemCooldown
IsCorruptedItem = IsCorruptedItem or C_Item.IsCorruptedItem
IsCosmeticItem = IsCosmeticItem or C_Item.IsCosmeticItem
IsDressableItem = IsDressableItem or C_Item.IsDressableItem or C_Item.IsDressableItemByID

-- Deprecated_PvpScript.lua
IsSubZonePVPPOI = IsSubZonePVPPOI or C_PvP.IsSubZonePVPPOI
GetZonePVPInfo = GetZonePVPInfo or C_PvP.GetZonePVPInfo
TogglePVP = TogglePVP or C_PvP.TogglePVP
SetPVP = SetPVP or C_PvP.SetPVP

-- Deprecated_SoundScript.lua
PlayVocalErrorSoundID = PlayVocalErrorSoundID or C_Sound.PlayVocalErrorSound

-- Deprecated_SpellScript.lua
TargetSpellReplacesBonusTree = TargetSpellReplacesBonusTree or C_Spell.TargetSpellReplacesBonusTree
GetMaxSpellStartRecoveryOffset = GetMaxSpellStartRecoveryOffset or C_Spell.GetSpellQueueWindow
GetSpellQueueWindow = GetSpellQueueWindow or C_Spell.GetSpellQueueWindow
GetSchoolString = GetSchoolString or C_Spell.GetSchoolString
